using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using MenuCommand = UnityEditor.MenuCommand;

public static class UIElementMenu
{
    [MenuItem("Tools/Build Execl Config", false, 5)]
    public static void BuildExeclConfig()
    {
        string frontPath = Application.dataPath;
        int tempPos = frontPath.IndexOf("Assets");
        string rootPath = frontPath.Substring(0, tempPos);

        string path = "Build_ExeclConfig.bat";
        Process proc = Process.Start(rootPath + path);
        proc.WaitForExit(); AssetDatabase.Refresh();
    }

    [MenuItem("Tools/Build Protobuf File", false, 5)]
    public static void BuildProtobufFile()
    {
        string frontPath = Application.dataPath;
        int tempPos = frontPath.IndexOf("Assets");
        string rootPath = frontPath.Substring(0, tempPos);

        string path = "Build_Protobuf.bat";
        Process proc = Process.Start(rootPath + path);
        proc.WaitForExit(); AssetDatabase.Refresh();
    }

    [MenuItem("CONTEXT/SerializeRoot/AddOrRemoveNode")]
    static void AddOrRemoveNode(MenuCommand command)
    {
        if (Application.isPlaying) { return; }
        var root = command.context as SerializeRoot;
        if (root != null) { root.OperateNode(); }
    }
}